/**
 * @Company: 北京慧点科技有限公司 | www.smartdot.com.cn
 * @Copyright 1998-2020 © Smartdot Technologies Co., Ltd.
 */
package com.springlearn.zhoufei.other.spring.demo2;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

public class HelloWorld5_1 {
    @Resource
    private HelloWorld5 HelloWorld5;
    @PreDestroy
    public void destroy() throws Exception {
        System.out.println("HelloWorld5_1：销毁对象前动作");
    }
    @PostConstruct
    public void init() throws Exception {
        System.out.println("HelloWorld5_1：对象初始化后动作");
    }
    public void sayHelloWorld() {
        System.out.println(HelloWorld5.toString());
    }
    public static void main(String[] args) {
        String pathHello = "./other\\Bean2.xml";
        AbstractApplicationContext context = new ClassPathXmlApplicationContext(pathHello);
        HelloWorld5_1 HelloWorld5_1 = (HelloWorld5_1) context.getBean("HelloWorld5_1");
        HelloWorld5_1.sayHelloWorld();
        // 关闭容器
        context.registerShutdownHook();
    }
}